//
//  ArabicWordCounter.swift
//  hello
//  Created by 赵康 on 2025/2/15.
//

import Foundation

enum ArabicWordCounter {
  static func countWords(_ text: String) -> Int {
    let pattern = "[\u{0600}-\u{06FF}]+"
    guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else { return 0 }
    let matches = regex.matches(
      in: text,
      options: [],
      range: NSRange(text.startIndex..., in: text)
    )
    return matches.count
  }
}
